package edu.unf.cen6940.service;

import edu.unf.cen6940.domain.Category;
import edu.unf.cen6940.domain.Generatedproduct;
import edu.unf.cen6940.domain.Student;
import edu.unf.cen6940.domain.Thesis;
import edu.unf.cen6940.domain.Thesiscommittee;
import edu.unf.cen6940.domain.Thesisstatus;
import edu.unf.cen6940.domain.Thesistool;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/rms_test-security-context.xml",
		"file:./resources/rms_test-service-context.xml",
		"file:./resources/rms_test-dao-context.xml",
		"file:./resources/rms_test-web-context.xml" })
@Transactional
public class ThesisServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected ThesisService service;

	/**
	 * Instantiates a new ThesisServiceTest.
	 *
	 */
	public ThesisServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Thesis entity
	 * 
	 */
	@Test
	public void countThesiss() {
		Integer response = null;
		response = service.countThesiss();
		// TODO: JUnit - Add assertions to test outputs of operation: countThesiss
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Thesiscommittee entity
	 * 
	 */
	@Test
	public void deleteThesisThesiscommittees() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesisThesiscommittees 
		Integer thesis_thesisId = 0;
		Integer related_thesiscommittees_thesisCommitteeId = 0;
		Thesis response = null;
		response = service.deleteThesisThesiscommittees(thesis_thesisId, related_thesiscommittees_thesisCommitteeId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteThesisThesiscommittees
	}

	/**
	 * Operation Unit Test
	 * Save an existing Generatedproduct entity
	 * 
	 */
	@Test
	public void saveThesisGeneratedproducts() {
		// TODO: JUnit - Populate test inputs for operation: saveThesisGeneratedproducts 
		Integer thesisId = 0;
		Generatedproduct related_generatedproducts = new edu.unf.cen6940.domain.Generatedproduct();
		Thesis response = null;
		response = service.saveThesisGeneratedproducts(thesisId, related_generatedproducts);
		// TODO: JUnit - Add assertions to test outputs of operation: saveThesisGeneratedproducts
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Category entity
	 * 
	 */
	@Test
	public void deleteThesisCategories() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesisCategories 
		Integer thesis_thesisId_1 = 0;
		Integer related_categories_categoryId = 0;
		Thesis response = null;
		response = service.deleteThesisCategories(thesis_thesisId_1, related_categories_categoryId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteThesisCategories
	}

	/**
	 * Operation Unit Test
	 * Save an existing Thesiscommittee entity
	 * 
	 */
	@Test
	public void saveThesisThesiscommittees() {
		// TODO: JUnit - Populate test inputs for operation: saveThesisThesiscommittees 
		Integer thesisId_1 = 0;
		Thesiscommittee related_thesiscommittees = new edu.unf.cen6940.domain.Thesiscommittee();
		Thesis response = null;
		response = service.saveThesisThesiscommittees(thesisId_1, related_thesiscommittees);
		// TODO: JUnit - Add assertions to test outputs of operation: saveThesisThesiscommittees
	}

	/**
	 * Operation Unit Test
	 * Return all Thesis entity
	 * 
	 */
	@Test
	public void findAllThesiss() {
		// TODO: JUnit - Populate test inputs for operation: findAllThesiss 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Thesis> response = null;
		response = service.findAllThesiss(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllThesiss
	}

	/**
	 * Operation Unit Test
	 * Save an existing Thesisstatus entity
	 * 
	 */
	@Test
	public void saveThesisThesisstatuses() {
		// TODO: JUnit - Populate test inputs for operation: saveThesisThesisstatuses 
		Integer thesisId_2 = 0;
		Thesisstatus related_thesisstatuses = new edu.unf.cen6940.domain.Thesisstatus();
		Thesis response = null;
		response = service.saveThesisThesisstatuses(thesisId_2, related_thesisstatuses);
		// TODO: JUnit - Add assertions to test outputs of operation: saveThesisThesisstatuses
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Thesistool entity
	 * 
	 */
	@Test
	public void deleteThesisThesistools() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesisThesistools 
		Integer thesis_thesisId_2 = 0;
		Integer related_thesistools_thesisToolId = 0;
		Thesis response = null;
		response = service.deleteThesisThesistools(thesis_thesisId_2, related_thesistools_thesisToolId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteThesisThesistools
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Student entity
	 * 
	 */
	@Test
	public void deleteThesisStudent() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesisStudent 
		Integer thesis_thesisId_3 = 0;
		Integer related_student_studentId = 0;
		Thesis response = null;
		response = service.deleteThesisStudent(thesis_thesisId_3, related_student_studentId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteThesisStudent
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Generatedproduct entity
	 * 
	 */
	@Test
	public void deleteThesisGeneratedproducts() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesisGeneratedproducts 
		Integer thesis_thesisId_4 = 0;
		Integer related_generatedproducts_generatedProductId = 0;
		Thesis response = null;
		response = service.deleteThesisGeneratedproducts(thesis_thesisId_4, related_generatedproducts_generatedProductId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteThesisGeneratedproducts
	}

	/**
	 * Operation Unit Test
	 * Save an existing Category entity
	 * 
	 */
	@Test
	public void saveThesisCategories() {
		// TODO: JUnit - Populate test inputs for operation: saveThesisCategories 
		Integer thesisId_3 = 0;
		Category related_categories = new edu.unf.cen6940.domain.Category();
		Thesis response = null;
		response = service.saveThesisCategories(thesisId_3, related_categories);
		// TODO: JUnit - Add assertions to test outputs of operation: saveThesisCategories
	}

	/**
	 * Operation Unit Test
	 * Save an existing Thesistool entity
	 * 
	 */
	@Test
	public void saveThesisThesistools() {
		// TODO: JUnit - Populate test inputs for operation: saveThesisThesistools 
		Integer thesisId_4 = 0;
		Thesistool related_thesistools = new edu.unf.cen6940.domain.Thesistool();
		Thesis response = null;
		response = service.saveThesisThesistools(thesisId_4, related_thesistools);
		// TODO: JUnit - Add assertions to test outputs of operation: saveThesisThesistools
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findThesisByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findThesisByPrimaryKey 
		Integer thesisId_5 = 0;
		Thesis response = null;
		response = service.findThesisByPrimaryKey(thesisId_5);
		// TODO: JUnit - Add assertions to test outputs of operation: findThesisByPrimaryKey
	}

	/**
	 * Operation Unit Test
	 * Load an existing Thesis entity
	 * 
	 */
	@Test
	public void loadThesiss() {
		Set<Thesis> response = null;
		response = service.loadThesiss();
		// TODO: JUnit - Add assertions to test outputs of operation: loadThesiss
	}

	/**
	 * Operation Unit Test
	 * Save an existing Thesis entity
	 * 
	 */
	@Test
	public void saveThesis() {
		// TODO: JUnit - Populate test inputs for operation: saveThesis 
		Thesis thesis = new edu.unf.cen6940.domain.Thesis();
		service.saveThesis(thesis);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Student entity
	 * 
	 */
	@Test
	public void saveThesisStudent() {
		// TODO: JUnit - Populate test inputs for operation: saveThesisStudent 
		Integer thesisId_6 = 0;
		Student related_student = new edu.unf.cen6940.domain.Student();
		Thesis response = null;
		response = service.saveThesisStudent(thesisId_6, related_student);
		// TODO: JUnit - Add assertions to test outputs of operation: saveThesisStudent
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Thesisstatus entity
	 * 
	 */
	@Test
	public void deleteThesisThesisstatuses() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesisThesisstatuses 
		Integer thesis_thesisId_5 = 0;
		Integer related_thesisstatuses_thesisStatusId = 0;
		Thesis response = null;
		response = service.deleteThesisThesisstatuses(thesis_thesisId_5, related_thesisstatuses_thesisStatusId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteThesisThesisstatuses
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Thesis entity
	 * 
	 */
	@Test
	public void deleteThesis() {
		// TODO: JUnit - Populate test inputs for operation: deleteThesis 
		Thesis thesis_1 = new edu.unf.cen6940.domain.Thesis();
		service.deleteThesis(thesis_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
